﻿@{
    Layout = null;

}

<!DOCTYPE html>
@*<script src="~/Content/js/jquery-2.1.4.min.js"></script>*@
<script type="text/javascript">
    function tz() {
        var id = $('#Hidden1').val();
        var kids =$('input[name="kc"]:checked');
      
       
        //alert( $('input[name="kc"]:checked').val());return

        if (kids.length <= 0) {
            alert("请选择课程");
        }
        else {
            var ids = "";
            for (var i = 0; i < kids.length; i++) {

                ids += kids[i].value + ",";
               
            }
            ids = ids.substring(0, ids.length - 1);
           

            $.post("/Class/AllAddCourse", { ids: ids }, function (data) {
                if (data == "1") {
                    location.href = '/Class/ClassCourse?id=' + id;
                }
            })
        }
    }

    //隐藏课程
    var ids = "";
    function delbtn(id) {
        $('#' + id).hide();
        ids += id + ",";
    }

    //批量删除课程
    function alldel() {
        var allids = ids;
        var id = $('#Hidden1').val();
        if (allids.length <= 0) {
            alert("请选择删除课程");
        }
        else {
            var bids = "";
            $.post("/Class/AllDelCourse", { allids: allids }, function (data) {
                if (data == "1") {
                    location.href = '/Class/ClassCourse?id=' + id;
                }
            })
        }
    }


    var RecordCount;//全局变量  总条数
    var PageSize = 5;//全局变量 每页显示多少条数据

    //点击查询时，开始分页
   
    //点击模态框按钮加载数据
    function aaa() {

        //传回数据总条数
        $.post('/Class/ClassCourse1/', { name: $('#_name').val() }, function (data) {
             //$('#num2222').html(data.length);
            RecordCount = data;
           // alert(data)
          
        })
        AjaxPage(1, PageSize);
    }
    //点击查询加载数据
    function sss() {

        //传回数据总条数
        $.post('/Class/ClassCourse1/', { name: $('#_name').val() }, function (data) {
            // $('#num2222').html(data);
        
           RecordCount =data;
           //alert(data)
        })
        AjaxPage(1, PageSize);

    }

    function AjaxPage(CurPage, PageSize) {

        //清空数据显示Table
        $('#SearchQuery_Table tbody').remove();
        $('#pageCount').html('0');
        $('#MainContent_AspNetPager_Msg').html(" <a disabled='disabled' style='margin-right:5px;'> 上一页</a><span class='cpb' style='margin-right:5px;'>1</span><a disabled='disabled' style='margin-right:5px;'>下一页 </a>");
        $('#CurrentPageSize').html(CurPage);//页

        //创建者
        var name = $('#_name').val();
        //alert(2); return
        $.post('/Class/ShowClassCourse', { pageSize: PageSize, pageIndex: CurPage, name: name }, function (data) {


            // alert(data); return
            var str = "";
            for (var i = 0; i < data.length; i++) {

               
                str += "<tr>";
                str += "<td><a class=\"course-picture-link\" href=\"/course/125\" target=\"_blank\"><img class=\"course-picture\" src=\"~/Content/images/" + data[i].CImage + "\" style=\"width:230px;height:130px;\" alt=\"课程封面\">  </a></td>";

                str += "<td style='width:100px'> <h4 class=\"course-title\"> <a href=\"/course/125\" target=\"_blank\"> " + data[i].CoursesName + " </a>  </h4></td>";
               // str += "<td style='width:100px'><a href=\"/user/4\" target=\"_blank\"><img src=\"~/Img/" + data[i].UserInfo.Avatar + "\" class=\"teacher-avatar\" style=\"width:30px;height:30px;\"></a></td>";
                str += "<td style='width:100px'> <a class=\"teacher-nickname ellipsis\" target=\"_blank\" href=\"/user/4\">" + (data[i].UserInfo.Uname == null ? "--" : data[i].UserInfo.Uname) + "</a>  <span class=\"teacher-title ellipsis\">讲师</span> </td>";
                str += "<span class=\"glyphicon glyphicon-ok pull-right\" style=\"z-index:100;color:#02b980;font-size:30px;\"></span>";
                str += "<td  style='width:60px'> <input type=\"checkbox\" style=\"width:30px;height:30px\"; name=\"kc\"  value='" + data[i].CoursesId + "' /></td>";
                str += "</tr>";
            }
            //alert(str);return
            $('#SearchQuery_Table').html(str);

            //总条数
            //RecordCount=$('#num2222').val();
            $('#pageCount').html(RecordCount);
            //alert(RecordCount);return
            //最大页数
            var maxpage = RecordCount % PageSize == 0 ? parseInt(RecordCount / PageSize) : (parseInt(RecordCount / PageSize) + 1);

            $('#MainContent_AspNetPager_Msg').html('');//分页链接
            var span = "<li><a style='margin-right: 5px; cursor: pointer;' href='javascript:void(0)' onclick='PageIndexClick(this)' id='TopPage' pageindex='0'> 上一页</a></li>";
            var firstPage = 0;

            var pagecount = 0;//循环的次数

            if (maxpage > 5) {
                pagecount = 5;
            } else {
                pagecount = maxpage;
            }
            if (CurPage > 5) {
                pagecount = CurPage;
                var firstPage = CurPage - 5;
                if (firstPage >= 1) {
                    span += "<li><a style='margin-right: 5px; cursor: pointer;' href='javascript:void(0)'  onclick='CurPageSizeClick(" + firstPage + ",this)' >...</a></li>";
                }
            }
            for (var j = firstPage + 1; j < pagecount + 1; j++) {
                if (j == CurPage) {
                    span += "<li><a class='cpb' style='margin-right: 5px; cursor: pointer;' onclick='CurPageSizeClick(" + j + ",this)'>" + j + "</a></li>";
                } else {
                    span += "<li><a style='margin-right: 5px; cursor: pointer;' href='javascript:void(0)'  onclick='CurPageSizeClick(" + j + ",this)' >" + j + "</a></li>";
                }
            }
            pagecount = pagecount + 1;
            if (maxpage >= pagecount) {
                span += "<li><a style='margin-right: 5px; cursor: pointer;' href='javascript:void(0)'  onclick='CurPageSizeClick(" + pagecount + ",this)' >...</a></li>";
            }
            span += "<li><a style='margin-right: 5px; cursor: pointer;' href='javascript:void(0)' onclick='PageIndexClick(this)' id='NextPage' pageindex='0'> 下一页</a></li>";
            $('#MainContent_AspNetPager_Msg').html(span);
        }
        )
    }



    //首页、上一页、下一页、尾页点击
    function PageIndexClick(obj) {
        //当前第几页
        var CurrenPageSize = $.trim($('#CurrentPageSize').html());
        if (CurrenPageSize != '') {
            CurrenPageSize = parseInt(CurrenPageSize);
        }
        //判断条件
        var type = $(obj).attr('id');
        //首页
        if (type == 'FirstPage') {
            CurrenPageSize = 1;
            AjaxPage(CurrenPageSize, PageSize);
            $('#CurrentPageSize').html('1');
        }
            //上一页
        else if (type == 'TopPage') {
            if (CurrenPageSize > 1) {
                CurrenPageSize = CurrenPageSize - 1;
            } else {
                CurrenPageSize = 1;
            }
            AjaxPage(CurrenPageSize, PageSize);
            $('#CurrentPageSize').html(CurrenPageSize);
        }
            //下一页
        else if (type == 'NextPage') {
            var size = CurrenPageSize + 1;
            var maxpage = RecordCount % PageSize == 0 ? parseInt(RecordCount / PageSize) : (parseInt(RecordCount / PageSize) + 1);
            if (size <= maxpage) {
                CurrenPageSize = CurrenPageSize + 1
            }
            AjaxPage(CurrenPageSize, PageSize);
            $('#CurrentPageSize').html(CurrenPageSize);
        }
            //尾页
        else if (type == 'LastPage') {
            CurrenPageSize = (RecordCount % PageSize == 0 ? parseInt(RecordCount / PageSize) : parseInt(RecordCount / PageSize) + 1);
            AjaxPage(CurrenPageSize, PageSize);
            $('#CurrentPageSize').html(CurrenPageSize);
        }
    }

    //页数点击
    function CurPageSizeClick(CurPage, obj) {
        $('#CurrentPageSize').html(CurPage);
        AjaxPage(CurPage, PageSize);
    }


</script>

<html>
<!-- 网页头部分布视图 -->
@Html.Partial("~/Views/Shared/HouTai_Header.cshtml")
<body>
    <!-- 网页导航菜单分布视图 -->
    @Html.Partial("~/Views/Shared/HouTai_DaoHang.cshtml")

    <div class="container">
        <div class="row">

            <!-- 网页头部分布视图 -->
            @Html.Partial("~/Views/Shared/ClassManage_Left_Menu.cshtml")


            <div class="col-md-10">

                <style>
                    .sort {
                        padding-top: 50px;
                        padding-right: 20px;
                        padding-left: 20px;
                    }

                    .price {
                        color: #e57259;
                        font-size: 16px;
                    }
                </style>

                <div class="panel panel-default panel-col">
                    <div class="panel-heading">
                        课程管理
                        <button class="btn btn-success btn-sm panel-bar" id="aaaa" onclick="aaa()" data-toggle="modal" data-target="#myModal">添加课程</button>
                    </div>
                    <div class="panel-body">
                        <form id="courses-form" class="form-horizontal" method="post">
                            <div class="alert alert-success" id="hid"></div>
                            <div class="form-group" id="courses-form-group">
                                <div class="col-md-12 controls">
                                    <ul class="course-list-group sortable-list course-wide-list courses-selected" id="course-list-group" data-role="list">

                                        @foreach (var item in ViewBag.cclist as List<LeEdu.MODEL.Course_Class>)
                                        {
                                            <li class="course-item item-138 clearfix" data-role="item" id="@item.ID">
                                                <input type="hidden" name="courseIds[]" value="138">
                                                <span class="glyphicon glyphicon-resize-vertical sort-handle sort"></span>    <a class="course-picture-link" href="http://www.zhishile.com/course/138" target="_blank">
                                                    <img class="course-picture" src="~/Content/images/@item.Courses.CImage" alt="sds " style="width:230px;height:129px;">
                                                </a>
                                                <button class="close delete-btn pull-right mrl mts mll" data-role="item-delete" type="button" title="删除" style="font-size:35px;" data-id="138" onclick="delbtn(@item.ID)">× </button>
                                                <div class="course-body">
                                                    <div style="float:right;" class="text-muted mrm mls">
                                                        <span class="course-price course-price-138" style="display:inline" data-price="0.00">
                                                            免费
                                                        </span>
                                                    </div>
                                                    <h4 class="course-title">
                                                        <a href="http://www.zhishile.com/course/138" target="_blank">@item.Courses.CoursesName </a>
                                                    </h4>
                                                    <div class="course-about ellipsis"></div>

                                                    <div class="course-footer clearfix">
                                                        <div class="teacher">
                                                            <a href="http://www.zhishile.com/user/4" target="_blank"><img src="~/Img/@item.Courses.UserInfo.Avatar" style="width:30px;height:30px;"></a>
                                                            <a class="teacher-nickname ellipsis" target="_blank" href="http://www.zhishile.com/user/4">@item.Courses.UserInfo.Uname</a>
                                                            <span class="teacher-title ellipsis">讲师</span>
                                                        </div>

                                                        <div class="course-metas">
                                                            <span class="text-muted text-sm">0学员</span>
                                                            <span class="divider"></span>

                                                            <span class="text-muted text-sm">
                                                                1个课时
                                                            </span>
                                                            <span class="divider"></span>
                                                            <span class="text-muted text-sm">
                                                                有效期:
                                                                永久
                                                            </span>
                                                        </div>
                                                    </div>
                                                </div>
                                            </li>
                                        }


                                    </ul>
                                </div>
                            </div>
                            <div class="alert alert-warning pull-right">若训练营课程被移除，则该课程内所有学习数据将被清空。</div>
                            <div class="form-group">
                                <div class="col-md-offset-9 col-md-3 controls">
                                    <div class="mbl pull-right">
                                        共计: &nbsp; &nbsp;
                                        <span class="price" style="display:inline">
                                            <span id="price">0</span>乐币

                                        </span>

                                    </div>
                                    <button type="submit" class="btn btn-fat btn-primary pull-right" onclick="alldel()">保存修改</button>
                                </div>
                            </div>

                            <input type="hidden" name="_csrf_token" value="cb19b82974a833c5dde99ed84d25566d21a8d842">
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <!-- 添加班级模态框 -->
        <input id="Hidden1" type="hidden" value="@Session["cid"]" />
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h4 class="modal-title">选择课程</h4>
                    </div>
                    <div class="modal-body">
                        <style>
                            .course-item:hover {
                                cursor: pointer;
                            }

                            .course-wide-list .course-item .select {
                            }
                        </style>
                        <div class="alert alert-info" role="alert">
                            加入训练营的课程为选中的原课程复制生成，并与原课程实时同步更新。如需解除同步，请对该课程进行编辑。
                        </div>
                        <form class="form-inline form-search">
                            <div class="form-group ">
                                <input class="form-control" name="_name" id="_name" value="" placeholder="课程名称" type="text">
                            </div>
                            <input type="button" id="ss" value="搜索" onclick="sss()" class="btn btn-primary" />

                            @*<a class="btn btn-primary" id="all-courses">全部课程</a>*@
                        </form>
                        <div class="row mtl">
                            <div class="col-md-12">
                                <div class="courses-list">

                                    <style>
                                        .course-wide-list .enabled:hover {
                                            background: #eee;
                                            border-color: #ddd;
                                        }

                                        .course-wide-list .enabled {
                                            cursor: default;
                                            background: #eee;
                                        }
                                    </style>
                                    <table class="table-bordered">

                                        <tbody class="course-wide-list" id="SearchQuery_Table">



                                        </tbody>
                                    </table>


                                    <div class="row" style="margin-top: 15px;">
                                        <div class="col-lg-12 col-sm-12 col-xs-12 col-xxs-12">
                                            <div style="font-size: 14px;">共<label style="color: #20A8D8; font-size: 14px;" id="pageCount"></label>条记录</div>

                                            @*<input type="hidden" id="num2222" value="@ViewBag.count" />*@
                                           
                                        </div>

                                    </div>
                                    <div class="row">
                                        <div class="col-lg-12 col-sm-12 col-xs-12 col-xxs-12">
                                            <ul id="MainContent_AspNetPager_Msg" class="pagination">

                                            </ul>
                                            <div class="hidden" id="CurrentPageSize">1</div>
                                            @*<div class="hidden" id="num2222">1</div>*@
                                            @*<input type="hidden" id="num2222" />*@
                                        </div>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button id="sure" class="btn btn-primary pull-right" data-url="/classroom/7/courses/select" onclick="tz()">添加</button>
                        <button type="button" class="btn btn-link pull-right" data-dismiss="modal">取消</button>
                        <script>app.load('classroombundle/controller/classroom/manage/course/pick')</script>
                    </div>
                </div>
            </div>
        </div>

        @*<input type="checkbox" id="aa" name="aaa" checked="checked" value="1111" />*@
    </div>

    <script>
        var app = {};
        app.debug = false;
        app.version = '6.9.3';
        app.httpHost = 'http://www.zhishile.com';
        app.basePath = '';
        app.theme = 'jianmo';
        app.themeGlobalScript = 'theme/global-script';
        app.jsPaths = { "common": "common", "theme": "\/themes\/jianmo\/js", "customwebbundle": "\/bundles\/customweb\/js", "customadminbundle": "\/bundles\/customadmin\/js", "topxiawebbundle": "\/bundles\/topxiaweb\/js", "topxiaadminbundle": "\/bundles\/topxiaadmin\/js", "classroombundle": "\/bundles\/classroom\/js" };
        app.crontab = '/common/crontab';

        var CKEDITOR_BASEPATH = app.basePath + '/assets/libs/ckeditor/4.6.7/';
        app.config = { "api": { "weibo": { "key": "" }, "qq": { "key": "" }, "douban": { "key": "" }, "renren": { "key": "" } }, "cloud": { "video_player": "http:\/\/cdn.staticfile.org\/GrindPlayerCN\/1.0.2\/GrindPlayer.swf", "video_player_watermark_plugin": "http:\/\/cdn.staticfile.org\/GrindPlayerCN\/1.0.2\/Watermake-1.0.3.swf", "video_player_fingerprint_plugin": "http:\/\/cdn.staticfile.org\/GrindPlayerCN\/1.0.2\/Fingerprint-1.0.1.swf" }, "loading_img_path": "\/assets\/img\/default\/loading.gif?6.9.3" };
        app.arguments = {};
        app.controller = 'user/list';

        app.scripts = null;

        app.uploadUrl = '/file/upload';
        app.imgCropUrl = '/file/img/crop';
        app.lessonCopyEnabled = '0';
        app.mainScript = '/bundles/topxiaadmin/js/admin-app.js?6.9.3';
    </script>
    <script src="/Content/js/sea.js?6.9.3"></script>
    <script src="/Content/js/seajs-style.js?6.9.3"></script>
    <script src="/Content/js/seajs-global-config.js?6.9.3"></script>
    <script>
        seajs.use(app.mainScript);
    </script>  <div id="modal" class="modal"></div>
    <div class="fixed-bar">
        <a href="/admin/feedback" target='_blank' class="icon-question-text feedback">
            <i class="es-icon es-icon-help"></i>
            <span>产品<br />反馈</span>
        </a>
    </div>
</body>

</html>
